/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package meteocal.business.boundary;

import java.util.Date;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import meteocal.business.entity.EventDeleted;
import meteocal.business.entity.Weather;

/**
 *
 * @author Francesca
 */
@Stateless
public class EventDeleteFacade extends AbstractFacade<EventDeleted>{
    @PersistenceContext(unitName = "meteocalPU")
    private EntityManager em;

    public EventDeleteFacade() {
        super(EventDeleted.class);
    }
    
    public void create(Integer idEvent, String name, Date startingDate, Date startingTime, Date endingDate, Date endingTime, String place, String creator){
        EventDeleted eventDeleted = new EventDeleted();
        eventDeleted.setIdEvent(idEvent);
        eventDeleted.setName(name);
        eventDeleted.setStartingDate(startingDate);
        eventDeleted.setStartingTime(startingTime);
        eventDeleted.setEndingDate(endingDate);
        eventDeleted.setEndingTime(endingTime);
        eventDeleted.setPlace(place);
        eventDeleted.setCreator(creator);
        em.persist(eventDeleted);
        em.flush();
        
    }
    
    
    public EventDeleted eventDetails(Integer idEvent){
        return em.createNamedQuery(EventDeleted.FIND_BY_IDEVENT, EventDeleted.class).setParameter("idEvent",idEvent).getSingleResult();
    }
    
    @Override
    protected EntityManager getEntityManager() {
       return em;
    }
}
